<?php
	$title = "Connexion"; 	
	require_once 'script/Application.php';
	require_once 'script/XMLFile.php';
?>	

<div class="admin_login">

	<div class="left_box">
		<div class="top_left_box"></div>
		<div class="center_left_box">
			<div class="box_title"><span>Admin</span> login</div>
			<form method="post" action="index.php?page=login.php">
				<div class="form">
					<div class="form_row">
						<label class="left">Login: </label>
						<input type="text" class="form_input" name="login"/>
					</div> 
					<div class="form_row">
						<label class="left">Mot de passe: </label>
						<input type="password" class="form_input" name="password"/>
					</div>                    
					<div style="float:right; padding:10px 25px 0 0;">
						<input type="submit" value="Se connecter"/>
					</div>
				</div>
			</form>
		</div>
		<div class="bottom_left_box"></div>
	</div> 
</div>               


<?php
if(isset($_POST['login']) && isset($_POST['password']))
{
	$login = $_POST['login'];
	$password = $_POST['password'];
	
	if(!empty($login) && !empty($password))
	{
		$file = new XML("script/user.xml");
		$file->load_file();
		if(Application::login($login, $password,$file) == true)
		{
			echo '<script language="javascript" type="text/javascript">
			window.location.replace("index.php");
			</script>';
		}	
	}
}
?>


